<?php
/**
 * Created by PhpStorm.
 * User: ai
 * Date: 2017/10/17
 * Time: 16:57
 */
use kartik\grid\GridView;
use yii\helpers\Html;
use kartik\editable\Editable;
use kartik\popover\PopoverX;

/* @var $this yii\web\View */

?>
<?php if ($contactDataProvider->count > 0): ?>
    <div class="row">
        <div class="col-sm-8 col-sm-offset-2">
            <?php

            echo GridView::widget([
                'dataProvider' => $contactDataProvider,
                'layout' => "{items}\n{summary}{pager}",
                'columns' => [
                    'contact',
                    'post',
                    'mobile',
//                    [
//                        'class' => 'kartik\grid\EditableColumn',
//                        'attribute' => 'contact',
//                        'pageSummary' => true,
//                        'refreshGrid' => true,
//                        'editableOptions' => function ($model, $key, $index) {
//                            return [
//                                'formOptions' => ['action' => ['/customer-contact/edit']],
//                            ];
//                        }
//                    ],
                    [
                        'attribute' => 'image',
                        'format' => 'raw',
                        'value' => function ($model) {
//                            return Html::img($model->image, ['height' => '60px']);
                            return PopoverX::widget([
                                'header' => '原图',
                                'type' => PopoverX::TYPE_DEFAULT,
                                'placement' => PopoverX::ALIGN_BOTTOM,
                                'content' => Html::img($model->image),
                                'toggleButton' => ['label' => Html::img($model->image, ['height' => '50px']), 'class' => 'btn btn-default'],
                            ]);
                        }
                    ],
                    [
                        'class' => '\kartik\grid\ActionColumn',
                        'viewOptions' => ['label' => false],
                        'updateOptions' => [],
                        'deleteOptions' => [],
                        'buttons' => [
                            'update' => function ($url, $model) {
//                                return $this->render('contact-edit', ['url' => $url, 'model' => $model]);
                                return Html::a('<span class="glyphicon glyphicon-pencil"></span>', ['customer-contact/update', 'id' => $model->id], ['target' => '_self']);
                            },
                            'delete' => function ($url, $model) {
                                return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['customer-contact/delete', 'id' => $model->id], ['class' => 'w1-action-del', 'title' => '删除', 'data-method' => 'post', 'data-pjax' => 0, 'data-confirm' => '确定要删除吗？',]);
                            }
                        ]
                    ],
                ],

                'bordered' => true,
                'striped' => true,
                'condensed' => true,
                'responsive' => true,
                'hover' => true,
//                    'showPageSummary' => true,
                'panel' => [
//                    'type' => GridView::TYPE_PRIMARY,
//                    'heading' => '沟通记录',
                ],
//                    'persistResize' => false,
            ]);
            ?>
        </div>
    </div>
<?php endif; ?>
